package com.hehe.controller;

import com.hehe.Common.IPUtil;
import com.hehe.DTO.PhotoDTO;
import com.hehe.POJO.Photo;
import com.hehe.POJO.Visitor_ip;
import com.hehe.Repository.*;
import com.hehe.Service.CollectService;
import com.hehe.Service.UserService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Controller
@RequestMapping(value = "")
public class IP_adressController {

    @Value("${config_file_name}")
    private String config_file_name;

    @Resource
    private ArticleRepository articleRepository;

    @Resource
    private Visitor_IP_Repository visitorIpRepository;

    @Resource
    private UserService userService;

    @Resource
    private CollectService collectService;

    @Resource
    private PhotoRepository photoRepository;

    @Resource
    private CollectRepository collectRepository;


    // 牛仔裤    迷你裙    超短裤     瑜伽裤  泳装   高跟鞋

    @GetMapping(value = "/visitors/ip/address")      //    @GetMapping("/type/photo/{type}")
    public String index(HttpServletRequest request, Model model,
                        @RequestParam(defaultValue = "牛仔裤") String type,
                        @RequestParam(defaultValue = "1") int page,
                        @RequestParam(defaultValue = "8") int size) {


        List<Visitor_ip> limit = visitorIpRepository.findByLimit(0, 20);
        model.addAttribute("visitors_ip", limit);
        return "ip-address.html";
    }




}




